<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<p>
    <input type="text" id="aaa">
    <textarea name="" id="data" cols="30" rows="10"></textarea>
    <button id="btn-post">发送</button>
</p>
<p>
    <label id="get-label">获取</label>
    <input type="text" id="get-data">
    <button id="get-btn">获取</button>
</p>
<script src="jquery.js"></script>
<script>
  $('#get-btn').click(function () {
    var a = $('#aaa'),
      b = $('#data'),
      c = $('#get-data').val();
    console.log(c);
    a.val("");
    b.val("");
    $.ajax({
      type: "POST",
      url: '../json/' + c + '.json',
      success: function (data) {
        alert('ok');
        console.log(data);
        data = JSON.stringify(data);
        a.val(c);
        b.val(data);
      },
      error: function (err) {
        console.log(err);
        alert('err' + err.status)
      }
    })
  });
  $('#btn-post').click(function () {
    var obj = {
      name: $('#aaa').val(),
      data: $('#data').val(),
      path: 'start'
    }
    $.ajax({
      type: 'POST',
      url: "http://localhost:8888/file",
      data: obj,
      success: function (data) {
        alert(data);
      },
      error: function (err) {
        console.log(err);
      }
    })
  });
</script>
</body>
</html>